<template>
  <div class="school">
    <h2>学校名字:{{ name }}</h2>
    <h2>学校地址:{{ address }}</h2>
    <button @click="getSchoolName">点击给Student传递学校名称</button>
  </div>
</template>

<script>
import pubsub from 'pubsub-js';
//暴露组件
export default {
  name: 'School',
  //data一定要写成函数
  data() {
    return {
      name: '尚硅谷atguigu',
      address: '北京-昌平',
    };
  },
  methods: {
    getSchoolName() {
      // this.$bus.$emit('getSchoolName', this.name);
      //发布消息
      pubsub.publish('hello', this.name);
    },
  },
};
</script>
<style scoped>
.school {
  background-color: aqua;
}
</style>
